package com.yeraphael.service.impl;

import com.yeraphael.entity.Dept;
import com.yeraphael.mapper.DeptMapper;
import com.yeraphael.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;


//@Priority(0)
@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;

    public List<Dept> list(){
        //1.调用mapper的方法，获取列表数据并返回
        return deptMapper.list();
    }

    @Override
    public Dept get(int id) {
        return deptMapper.get(id);
    }

    @Override
    public void delete(Integer id) {
        deptMapper.delete(id);
    }

    @Override
    public void save(Dept dept) {

        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());

        deptMapper.insert(dept);
    }

    @Override
    public Dept getByid(Integer id) {
        Dept dept = deptMapper.selectByid(id);
        return dept;
    }

    @Override
    public void update(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.update(dept);
    }


}

